<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<html>
  <head>
    <title>${appname}</title>
	<%@include file="../meta.jsp"%>
	<script src="${ctx}/includes/jquery.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript" src="${ctx}/js/lhgdialog/lhgdialog.js" charset="utf-8"></script>
	<script src="${ctx}/js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script src="${ctx}/includes/jquery.form.js" type="text/javascript"></script>
	<script src="${ctx}/includes/jquery.validate.js" type="text/javascript"></script>
	
	<script type="text/javascript">
		$(function(){
			$("#ccsq_add_form").validate({
				errorPlacement: function(error, element){
		            $(element).next('.field_notice').hide();
		            $(element).after(error);
		       },
			   success: function(label){   
			       label.addClass('right').text('OK!');
			   },
			   rules:   
			   {
			    	cclx : {required : true},
	            	zyfzcj : {required : true},
	            	ccly : {required : true},
	            	shrxm:{required : true}
			   },   
			   message:{
			    	cclx : {required : '请填写出差类型'},
	            	zyfzcj : {required : '请填写层级'},
	            	ccly : {required : '请填写出差理由'},
	            	shrxm:{required : '请选择审核人'}
			   },
			   submitHandler: function() {
			   		addSq();
			   }
			});  
		});
		
	</script>
  </head>
  
  <body>
    <div class="Teg_body">
    	<%@include file="../header.jsp"%>
    	
    	<div class="Teg_content">
    		<div class="content_left i-pane" id="zhd_LeftPane" paneid="LeftPane">
    			<div class="m-second-menu-title">
	    			<span class="Head">出差申请</span>
    			</div>
    			<div class="m-second-menu-ct ZHDAlignleft">
	    			<div class="accordion-3-container">
	    				<ul class="accordion-3">
	    					<li class="active"><div class="level-first"><a href="${ctx}/pubCcsq/create.do">出差申请</a></div></li>
	    					<li><div class="level-first"><a href="${ctx}/pubCcsq/myList.do">我的出差申请</a></div></li>
	    				</ul>
	    			</div>
    			</div>
    			
    			<%@include file="../leftmenu.jsp"%>
    		</div>
    		<div class="content_right">
    			<div class="second_breadcrumb">
    				<span class="current_position">您的当前位置：<a href="${ctx}">首页</a>></span><span><a href="${ctx}/pubCcsq/create.do" class="SkinObject">出差申请</a></span>
    			</div>
    			<div class="content_ct i-pane" id="zhd_ContentPane" style="margin-top: 5px;">
    				<s:form action="pubCcsq/save.do" method="post" id="ccsq_add_form">
    				<s:token></s:token>
    				<table class="form-table">
    					<tr>
							<th width="150">员工编号：</th>
							<td>${ygbh }</td>
						</tr>
						<tr>
							<th width="150">员工姓名：</th>
							<td>${ygxm }</td>
						</tr>
						<tr>
							<th width="150">出差类型：</th>
							<td>
							<mytag:select id="cclx" title="请输入出差类型" name="cclx" sql="basedata" isSql="false" condition="102" dataType="Long" listKey="name" listValue="name" headerKey="" headerValue="请选择"/>
							</td>
						</tr>
						<tr>
							<th width="150">职业发展层级：</th>
							<td>
							<mytag:select id="zyfzcj" title="请输入职业发展层级" name="zyfzcj" sql="basedata" isSql="false" condition="103" dataType="Long" listKey="name" listValue="name" headerKey="" headerValue="请选择"/>
							</td>
						</tr>
						<tr>
							<th width="150">出差理由：</th>
							<td>
							<textarea rows="4" name="ccly" style="width:400px;" title="请输入出差理由"></textarea>
							</td>
						</tr>
						<tr>
							<th width="150">审核人：</th>
							<td>
							<input type="hidden" name="spr" id="zrrbh"/>
							<s:textfield key="shrxm" title="请输入审核人" cssClass="form-txtinput" id="zrr" maxlength="20"/>
							</td>
						</tr>
						
					</table>
					<div class="win-btn-panel">
						<input class="btn-short" type="button" onclick="addSq()" value="提交申请" title="点击提交出差申请">
					</div>
    				
    				</s:form>
    			</div>
    		</div>
    		<div class="clear"></div>
    		
    	</div>
    	<%@include file="../bottom.jsp"%>
    </div>
  </body>
</html>
<script type="text/javascript">

$('#zrr').click(function(){
	$.dialog({
	  	id:'abc', 
	  	title:'选择人员', 
	  	content: 'url:${ctx}/pub/userByDeptSelect.jsp?timestamp='+new Date().getTime(), 
	  	max:false,
	  	min:false,
	  	width:600, 
	  	height:450,
	  	ok: function(){ 
	       	var m = abc.selectOnlyUser();
	        return m; 
	    }, 
	    cancelVal: '关闭', 
	    cancel: true
  	});
});

function addSq(){
	var v = $("#ccsq_add_form").valid();
	if(v){
		$('#ccsq_add_form').ajaxSubmit(resultHandler);
    	return false;
	}
}

function resultHandler(responseXML){
	var result = responseXML.getElementsByTagName("result")[0].firstChild.nodeValue;
	var message = responseXML.getElementsByTagName("error-message")[0].firstChild.nodeValue;
	var errorType = responseXML.getElementsByTagName("error-type")[0].firstChild.nodeValue;
	if(!eval(result)&&(errorType!=2)){
		alert(message);
	}else{
		var curDate = new Date(); 
		alert(message);
		location.replace("${ctx}/pubCcsq/create.do?timsStamp=" + curDate.getTime());
	}
}

function selectUser(){
  $.dialog({
  	id:'abc', 
  	name:'abc',
  	title:'选择人员', 
  	content: 'url:${ctx}/pub/userAllSelect.jsp?timestamp='+new Date().getTime(), 
  	max:false,
  	min:false,
  	width:600, 
  	height:450,
  	ok: function(){ 
       	abc.selectMoreUser();
        return true; 
    }, 
    cancelVal: '关闭', 
    cancel: true
  });
}

</script>
 
